import favicons from 'favicons';
import { promises as _promises } from 'fs';
import { join } from 'path';
const { readFile } = _promises;
export const generateFavicons = async (mintConfig, contentDirectoryPath) => {
    if (mintConfig.favicon == null)
        return;
    const desiredPath = join(contentDirectoryPath, mintConfig.favicon);
    const favicon = await readFile(desiredPath);
    try {
        return favicons(favicon, faviconConfig(mintConfig.name));
    }
    catch (err) {
        if (typeof err === 'object' && err != null && 'message' in err)
            console.log(err.message); // Error description e.g. "An unknown error has occurred"
    }
};
const faviconConfig = (name) => ({
    path: '/favicons',
    appName: name,
    appShortName: name,
    appDescription: undefined,
    developerName: undefined,
    developerURL: undefined,
    dir: 'auto',
    lang: 'en-US',
    background: '#fff',
    theme_color: '#fff',
    appleStatusBarStyle: 'black-translucent',
    display: 'standalone',
    orientation: 'any',
    scope: '/',
    start_url: '/?homescreen=1',
    preferRelatedApplications: false,
    relatedApplications: undefined,
    version: '1.0',
    logging: false,
    pixel_art: false,
    loadManifestWithCredentials: true,
    manifestMaskable: false,
    icons: {
        android: ['android-chrome-192x192.png', 'android-chrome-256x256.png'],
        appleIcon: ['apple-touch-icon.png'],
        appleStartup: false,
        favicons: true,
        windows: ['mstile-150x150.png'],
        yandex: false,
        firefox: false,
    },
});
